require.config({
    baseUrl:"./",
    paths:{
        gg: "./modules/getGoods1",
        ir: "./modules/secondRender",
        sl: "./modules/setLocal"
    }
})


require(["gg","ir","sl"],function(getGoods1, render, setLocal){
    const url = "http://localhost:3000/api";
    const cont = $(".cont");
     const goods=localStorage.getItem("goods")
    
    // console.log(goods);
    getGoods1(url, res=>{
        res = JSON.parse(res).msg;
        // console.log(res);
        const j = 20;
        $("#setPageDiv").pagination(res.length, {
            items_per_page: 20,
            num_display_entries: 2,
            num_edge_entries: 2,
            prev_text: "前一页",
            next_text: "下一页",
            callback:(i)=>{
                let index = i;
                // 3. 渲染页面
                render(res,index,j);
            }
        })
    })
    cont.on("click",".item-option",function(){

        const id = $(this).parent().attr("index");
        const pri = $(this).prev().children().html();
        // console.log(pri);
        // const price =pri.splice("￥");
        // console.log(id)
        // console.log($(this));
        // const num=$(this).num
        
    // console.log($(this).num);
        const price=pri.slice(1,5)
        // console.log(price);
        setLocal(id, price,);
        // console.log(num);

       
    })
})
